﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.AreaCommand;
using SheepStorage.API.Application.Command.PlaceCommand;
using SheepStorage.API.Application.Command.ProvinceCommand;
using SheepStorage.API.Application.Command.SheepManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace SheepStorage.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProvinceController : ControllerBase
    {
        private readonly IMediator _mediator;


        public ProvinceController(IMediator mediator)
        {
            _mediator = mediator;

        }

        /// <summary>
        /// 省份显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<List<Province>>> GetProvinces()
        {
            var list = new ProvinceListCommand();
            return await _mediator.Send(list);
        }

        /// <summary>
        /// 区域显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<List<Area>>> GetAreae(AreaListCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        ///地方显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Results<List<Place>>> GetPlace(PlaceListCommand command)
        {
            return await _mediator.Send(command);
        }

    }
}
